package com.xinchuang.domain.type;

import com.xinchuang.domain.vo.out.*;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Description:通用对外报价单分表枚举
 * @Author: thh
 * @Date: 2023/9/23 12:45
 */
public enum NormalQrQuotationaSubEnum {

    MACHINING_MATERIAL_COST("加工材料费/ Machining Material Cost（A）", "machining_material_cost", MachiningMaterialCost.class),
    HEAT_TREATMENT("热处理/Heat Treatment (B)", "heat_treatment", HeatTreatmentCost.class),
    ASSEMLY_MATERIAL_COST("装配材料费/Assemly Material Cost (C)", "assemly_material_cost", AssemlyMaterialCost.class),
    DESIGN_FEE("设计费/Design Cost (D)", "design_fee", DesignFee.class),
    MANUFACTURING_COST("加工费/ Manufacturing Cost (E)", "manufacturing_cost", ManufacturingCost.class),
    CMM_MEASURE("三坐标测量费CMM Measure (F)", "cmm_measure", Cmmmeasure.class),
    OTHER_FEE("其它费用/Other Fee (G=H+I+J+K)", "other_fee", OtherFee.class);

    private String cn;

    private String en;

    private Class className;

    private NormalQrQuotationaSubEnum(String cn, String en, Class className) {
        this.cn = cn;
        this.en = en;
        this.className = className;
    }

    public String getCn() {
        return cn;
    }

    public String getEn() {
        return en;
    }

    public Class getClassName() {
        return className;
    }

    /**
     * 根据中文名称获取英文名称
     *
     * @param cn
     * @return
     */
    public static String getEn(String cn) {
        Optional<NormalQrQuotationaSubEnum> result = Arrays.stream(NormalQrQuotationaSubEnum.values())
                .filter(normalOutQuotationaSub -> normalOutQuotationaSub.getCn().equals(cn))
                .findFirst();
        if (result.isPresent()) {
            return result.get().getEn();
        }
        return null;
    }

    /**
     * 根据中文名称获取对应的Class
     * @param cn
     * @return
     */
    public static Class<?> getClass(String cn) {
        Optional<NormalQrQuotationaSubEnum> result = Arrays.stream(NormalQrQuotationaSubEnum.values())
                .filter(normalOutQuotationaSub -> normalOutQuotationaSub.getCn().equals(cn))
                .findFirst();
        if (result.isPresent()) {
            return result.get().getClassName();
        }
        return null;
    }

}
